<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/axios.min.js"></script>
    <script type="text/javascript" src="../js/vue-router.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <link type="text/css" rel="stylesheet" href="../css/bootstrap.min.css">
</head>

<body>
    <div class="container" id="app">
        <div class="row">
            <button class="btn btn-default col-md-6" @click="login">登录</button>
            <button class="btn btn-default col-md-6" @click="register">注册</button>
        </div>
        <div class="row">
            <login-temp v-if="flag"></login-temp>
            <register-temp v-else></register-temp>
        </div>
    </div>

    <template id="loginTemp">
        <form>
            <h3>登录界面</h3>
            <div class="form-group">
                <label for="usernameLogin">username</label>
                <input type="text" id="usernameLogin" class="form-control" placeholder="enter your username">
            </div>
            <div class="form-group">
                <label for="passwordLogin">password</label>
                <input type="password" id="passwordLogin" class="form-control" placeholder="enter your password">
            </div>
            <button class="btn btn-default col-md-12">登录</button>
        </form>
    </template>

    <template id="registerTemp">
        <form>
            <h3>注册界面</h3>
            <div class="form-group">
                <label for="usernameRegister">username</label>
                <input type="text" id="usernameRegister" class="form-control" placeholder="enter your username">
            </div>
            <div class="form-group">
                <label for="passwordRegister">password</label>
                <input type="password" id="passwordRegister" class="form-control" placeholder="enter your password">
            </div>
            <button class="btn btn-primary col-md-12">注册</button>
        </form>
    </template>

    <script>
        Vue.component('login-temp', {
            template: '#loginTemp'
        });

        Vue.component('register-temp', {
            template: '#registerTemp'
        })

        var vm = new Vue({
            el: '#app',
            data: {
                flag: true
            },
            methods: {
                login() {
                    this.flag = true
                },
                register() {
                    this.flag = false
                }
            }
        });
    </script>
</body>

</html>